package com.sicheng.lc.周赛.分类.哈西表or计数or滑动窗口or双指针.双指针;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/9/30 20:16
 */
public class 最长的字母序连续子字符串的长度 {
    //https://leetcode.cn/problems/length-of-the-longest-alphabetical-continuous-substring/
    public int longestContinuousSubstring(String s) {
        int res = 1;
        int c = 1;
        for (int i = 0; i < s.length(); i++) {
            if (i + 1 < s.length()) {
                if (s.charAt(i) + 1 == s.charAt(i + 1)) {
                    c++;
                } else {
                    c = 1;
                }
            }
            res = Math.max(res, c);
        }
        return res;
    }
}
